<template>
  <div class="box-container">
    <el-table
      :data="rolesList"
      border
      stripe
      style="width: 100%"
    >
      <el-table-column
        type="index"
        label="#"
        width="48"
      />
      <el-table-column
        prop="authName"
        label="权限名称"
      />
      <el-table-column
        prop="path"
        label="路径"
      />
      <el-table-column
        label="权限等级"
      >
        <template slot-scope="{row}">
          <el-tag v-if="row.level==='0'">一级</el-tag>
          <el-tag v-else-if="row.level==='1'" type="success">二级</el-tag>
          <el-tag v-else type="warning">三级</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getPermissionData } from '@/api/rights'
export default {
  name: 'Rights',
  data() {
    return {
      rolesList: []
    }
  },

  created() {
    this.loadRolesList()
  },

  methods: {
    // 加载所有权限列表
    async loadRolesList() {
      const res = await getPermissionData('list')
      this.rolesList = res
    }
  }
}
</script>

<style scoped lang='scss'>

</style>
